package com.qire.manhua.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.qire.antscore.annotation.RouteMapping;
import com.qire.antsrouter.inject.Autowired;
import com.qire.common.constant.Navigation;
import com.qire.common.inject.EventControllerInjector;
import com.qire.common.support.base.BaseFragment;
import com.qire.manhua.R;
import com.qire.manhua.controller.BookshelfHistoryController;
import com.qire.manhua.databinding.FragmentBookshelfHistoryBinding;
import com.qire.manhua.model.viewModel.impl.BookshelfHistoryViewModel;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

/**
 * 首页->书架->历史
 */
@RouteMapping(path = Navigation.Fragment.BookshelfHistoryFragment)
public class BookshelfHistoryFragment extends BaseFragment<FragmentBookshelfHistoryBinding> {

    @Autowired
    BookshelfHistoryViewModel viewModel;

    @Autowired(injector = EventControllerInjector.class)
    BookshelfHistoryController controller;

    @Override
    public int layoutRid() {
        return R.layout.fragment_bookshelf_history;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        FragmentBookshelfHistoryBinding binder = viewDataBinder(inflater,container);
        binder.setBookshelfHistoryViewModel(viewModel);

        viewModel.onAddition(controller);
        controller.onAddition(viewModel);

        return binder.getRoot();
    }

    @Override
    public void onResume() {
        super.onResume();
        viewModel.loadHistoryList();
    }
}
